﻿@model PagedList<ChargeInfo>
@{
    var customer = (Customer)ViewBag.Customer;
    var p = (Kongt.IServices.QueryModel.ChargeQuery)ViewBag.p;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/css/select.css" rel="stylesheet" type="text/css" />
    <link href="/css/chargeinfo.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script src="/js/jquery.form.js"></script>
    <script type="text/javascript" src="/js/jquery.idTabs.min.js"></script>
    <script type="text/javascript" src="/js/select-ui.min.js"></script>


    <script type="text/javascript">
        var api = {
            searchCustomer: '/user/FindByCustomerId',
            updateStat: '/charge/UpdateChargeStat'
        }

        $(document).ready(function (e) {
            $(".select1").uedSelect({
                width: 345
            });
            $(".select2").uedSelect({
                width: 167
            });
            $(".select3").uedSelect({
                width: 100
            });

            $('#shouldPay').keyup(Charge);
            $('#hasGet').keyup(Charge);
            $('#shouldReturn').keyup(Charge);


        });

        ///计算
        function Charge(e) {
            var shouldPay = parseFloat($('#shouldPay').val());
            var hasGet = parseFloat($('#hasGet').val());
            var shouldReturn = (hasGet - shouldPay).toFixed(2);
            $('#shouldReturn').val(shouldReturn);
        }

        ///搜索
        function Search() {
            var customerId = $('#ul1').find("[name = 'UserCustomerId']").val();
            $.post(api.searchCustomer, { customerId: customerId }, function (data) {
                if (data.Succeed) {
                    $('#ul1').find('[name="CustomId"]').val(data.Obj.Id);
                    GetShouldCharges();
                } else {
                    alert(data.Msg);
                }

            }, 'json')
        }


        ///获取查询的用户需要交费的数据
        function GetShouldCharges() {
            var userId = $('#ul1').find('[name="CustomId"]').val();
            $('#form1').submit();
        }


        ///更新状态
        function updateStat() {
            var ids = [];
            $('#table1 tbody').find('tr').each(function () {
                var dv = $(this).attr('data-value');
                if (dv) {
                    ids.push(dv);
                }
            })
            if (ids.length > 0) {
                var  colectType=@((int)p.colectType);
                $.post(api.updateStat, { stat: 1,colectType: colectType,ids: ids.join(',') }, function (data) {
                    if (data.Succeed) {
                        alert(data.Msg);
                    }
                    else {
                        alert(data.Msg);
                    }

                }, 'json')
            }

        }



    </script>
</head>

<body>

    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <li><a href="#">首页</a></li>
            <li><a href="#">收费管理</a></li>
            <li><a href="#">窗口收费</a></li>
        </ul>
    </div>

    <div class="formbodycharge">


        <div class="userinfocharge">
            用户信息
        </div>
        <div id="tab2" class="tabsoncharge">
            <form id="form1">

                <ul class="seachformcharge" id="ul1">
                    <li>
                        <label>用户编号:</label><input type="text" name="UserCustomerId" value="@(customer?.CustomerId)" class="scinput" />
                    </li>
                    <li><label>用户姓名:</label><input type="text" value="@(customer?.CustomerName)" name="CustomerName" class="scinput" /></li>
                    <li><label>身份证号:</label><input type="text" value="@(customer?.PersonId)" name="PersonId" class="scinput" /></li>
                    <li><label>联系电话:</label><input type="text" value="@(customer?.LinkPhone)" name="LinkPhone" class="scinput" /></li>
                    <li><label>房屋类型:</label><input type="text" value="@(((Customer.HouseTypeEnum?)customer?.HouseType)?.ToDescription())" name="HouseType" class="scinput" disabled="disabled" style="background:#EFEFEF" /></li>
                    <li><label>区域地址:</label><input type="text" value="@(customer?.FirstArea+"-"+customer?.SecondArea)" name="FirstArea" class="scinput" disabled="disabled" style="background:#EFEFEF" /></li>
                    <li><label>详细地址: </label><input type="text" value="@(customer?.DetailAddress)" name="DetailAddress" class="scinput" disabled="disabled" style="background:#EFEFEF" /></li>
                    <li><label>用水类型:</label><input type="text" value="@(customer?.WaterType.TypeName)" name="WaterTypeName" class="scinput" disabled="disabled" style="background:#EFEFEF" /></li>
                    <li>
                        <label>&nbsp;</label>
                        @Html.Hidden("CustomId", customer?.Id.ToString())
                        @Html.Hidden("colectType", Request["colectType"])
                        <input name="" type="button" class="scbtn" value="查询" onclick="Search()" />
                    </li>
                </ul>
            </form>
            <table class="tablelistcharge" id="table1">
                <thead>
                    <tr>
                        <th>流水号<i class="sort"><img src="/images/px.gif" /></i></th>
                        <th>费用时间</th>
                        <th>上期时间</th>
                        <th>上期底数</th>
                        <th>本期时间</th>
                        <th>本期底数</th>
                        <th>用水量</th>
                        <th>单价</th>
                        <th>水费金额</th>
                        <th>附加费</th>
                        <th>滞纳金</th>
                        <th>合计金额</th>
                        <th>状态</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null)
                    {
                        foreach (var item in Model)
                        {
                            <tr data-value="@(item.Id)">
                                <td>@(item.Id)</td>
                                <td>@(item.ChargeName)</td>
                                <td>@(item.LastTime)</td>
                                <td>@(item.LastMeterShow)</td>
                                <td>@(item.ThisTime)</td>
                                <td>@(item.ThisMeterShow)</td>
                                <td>@(item.WaterMuch)</td>
                                <td>@(item.WaterPrice)</td>
                                <td>@(item.TotalWaterPrice)</td>
                                <td>@(item.ExtendPrice)</td>
                                <td>@(item.LateFee)</td>
                                <td>@(item.TotalPrice)</td>
                                <td>@(((ChargeInfo.StateEnum)item.State).ToDescription())</td>
                            </tr>
                        }

                        <tr>
                            <td></td>
                            <td>总计金额</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td><font color="ff0000">@(Model.Sum(item => item.TotalPrice))</font></td>
                            <td></td>
                        </tr>
                    }
                </tbody>

            </table>

        </div>



        <div id="tab2" class="tabson">


            <ul class="seachformchargesf">
                <li>
                    <label>应收金额:</label><font color="ff0000">
                        @if (Model != null)
                        {
                            <input type="text" value="@(Model.Sum(item => item.TotalPrice).Value.ToString("f2"))" class="scinputchargesfred" readonly="readonly" style="background:#EFEFEF" id="shouldPay" />
                        }
                        else
                        {
                            <input type="text" value="" class="scinputchargesfred" readonly="readonly" style="background:#EFEFEF" id="shouldPay" />
                        }

                    </font>
                </li>
                @*<li><label>预付余额:</label><input type="text" value="0.00" class="scinputchargesf" disabled="disabled" style="background:#EFEFEF" id="hasGet" />
                    </li>*@
                <li><label>收款金额: </label><input type="text" value="" class="scinputchargesfgreen" id="hasGet" /></li>
                <li><label>本次找零:</label><input type="text" value="" class="scinputchargesfred" readonly="readonly" style="background:#EFEFEF" id="shouldReturn" /></li>
                <li>
                    <label>&nbsp;</label>
                    <input name="" type="button" class="scbtnchargesf" value="收费" onclick="updateStat()" />
                </li>

            </ul>
        </div>
    </div>
</body>

</html>
